repo: Make locking per-OstreeRepo
authorDan Nicholson <dbn@endlessos.org>
Fri, 16 Apr 2021 15:55:40 +0000 (09:55 -0600)
committerDan Nicholson <dbn@endlessos.org>
Sat, 5 Jun 2021 15:15:32 +0000 (09:15 -0600)
commitccef9784d76c032b00ce5524fbfba39fa732b2fd
treed1d506170a8ec345960acaada2817deee8d582fe
parenteb09207e1abd7499bd92866cce1de6148d659a4a
repo: Make locking per-OstreeRepo

Previously each thread maintained its own lock file descriptor
regardless of whether the thread was using the same `OstreeRepo` as
another thread. This was very safe but it made certain multithreaded
procedures difficult. For example, if a main thread took an exclusive
lock and then spawned worker threads, it would deadlock if one of the
worker threads tried to acquire the lock.

This moves the file descriptor from thread local storage to the
`OstreeRepo` structure so that threads using the same `OstreeRepo` can
share the lock. A mutex guards against threads altering the lock state
concurrently.

Fixes: #2344
src/libostree/ostree-repo-private.h
src/libostree/ostree-repo.c